function TipBox(cfg) {
    this.config = {
        width: 300,
        height: 300,
        str: '正在处理',
        windowDom: window,
        setTime: 0,
        hasMask: true,
        hasMaskWhite: false,
        clickDomCancel: false,
        callBack: null,
        type: 'success'
    }
    $.extend(this.config, cfg);

    //存在就retrun
    if (TipBox.prototype.boundingBox) return;

    //初始化
    this.render(this.config.type);
    return this;
}
;

//外层box
TipBox.prototype.boundingBox = null;

//渲染
TipBox.prototype.render = function (tipType, container) {
    this.renderUI(tipType);

    //绑定事件
    this.bindUI();

    //初始化UI
    this.syncUI();
    $(container || this.config.windowDom.document.body).append(TipBox.prototype.boundingBox);
};

//渲染UI
TipBox.prototype.renderUI = function (tipType) {
    TipBox.prototype.boundingBox = $("<div id='animationTipBox'></div>");
    tipType == 'tip' && this.tipRenderUI();
    TipBox.prototype.boundingBox.appendTo(this.config.windowDom.document.body);

    //是否显示遮罩
    if (this.config.hasMask) {
        this.config.hasMaskWhite ? this._mask = $("<div class='mask_white'></div>") : this._mask = $("<div class='mask'></div>");
        this._mask.appendTo(this.config.windowDom.document.body);
    }

    //定时消失
    _this = this;
    !this.config.setTime && typeof this.config.callBack === "function" && (this.config.setTime = 1);
    this.config.setTime && setTimeout(function () {
        _this.close();
    }, _this.config.setTime);
};

TipBox.prototype.bindUI = function () {
    _this = this;

    //点击空白立即取消
    this.config.clickDomCancel && this._mask && this._mask.click(function () {
        _this.close();
    });
};
TipBox.prototype.syncUI = function () {
    TipBox.prototype.boundingBox.css({
        width: this.config.width + 'px',
        height: this.config.height + 'px',
        marginLeft: "-" + (this.config.width / 2) + 'px',
        marginTop: "-" + (this.config.height / 2) + 'px'
    });
};

//提示效果UI
TipBox.prototype.tipRenderUI = function () {
    var tip = "<div class='tip' style='text-align:center'>";
    tip += "<img src='/zb/img/code_superhunter8.jpg' width=200; height=200 style='margin: 0 auto'>";
    tip += "<div class='dec_txt'>" + this.config.str + "</div>";
    tip += "</div>";
    TipBox.prototype.boundingBox.append(tip);
};


//关闭
TipBox.prototype.close = function () {
    TipBox.prototype.destroy();
    this.destroy();
    this.config.setTime && typeof this.config.callBack === "function" && this.config.callBack();
};

//销毁
TipBox.prototype.destroy = function () {
    this._mask && this._mask.remove();
    TipBox.prototype.boundingBox && TipBox.prototype.boundingBox.remove();
    TipBox.prototype.boundingBox = null;
};
